/**
 * 
 */
package com.wgo.precise.client.common.session;

import com.wgo.precise.client.PreciseHessianRemoteServicesFactory;
import java.net.URL;

import com.wgo.bpot.client.session.LightSession;
import com.wgo.bpot.domain.common.AuthenticationHandler;
import com.wgo.bpot.server.persist.Persistent;
import com.wgo.precise.service.PreciseServices;
import com.wgo.precise.wiring.common.PreciseDomainModelConvention;

/**
 * @author peide3
 *
 */
public class PreciseSessionImpl extends LightSession<Persistent,PreciseServices> implements PreciseSession {

    public PreciseSessionImpl(URL remoteUrl, PreciseServices services ) {
        super(services ,new PreciseDomainModelConvention(), remoteUrl);
    }    

    public PreciseSessionImpl(URL remoteUrl, AuthenticationHandler authenticationHandler) {
        this(remoteUrl, new PreciseHessianRemoteServicesFactory(remoteUrl, authenticationHandler).createServices() );
    }    
    
	/**
	 * @see com.wgo.precise.client.common.session.PreciseSession#exportToXml(com.wgo.precise.client.common.session.PreciseSession.ObjectHolder)
	 */
	public void exportToXml(ObjectHolder<byte[]> objectHolder) {
		objectHolder.setObject(getServices().exportToXml());
	}

	/**
	 * @see com.wgo.precise.client.common.session.PreciseSession#getPdf(com.wgo.bpot.common.removeme.Persistent, com.wgo.precise.client.common.session.PreciseSession.ObjectHolder)
	 */
	public void getPdf(Persistent persistent, ObjectHolder<byte[]> objectHolder) {
		objectHolder.setObject(getServices().getPdf((Class<? extends Persistent>)persistent.getClass().getInterfaces()[0], persistent.getDbId()));
	}

	/**
	 * @see com.wgo.precise.client.common.session.PreciseSession#importFromXml(java.io.File, com.wgo.precise.client.common.session.PreciseSession.ObjectHolder)
	 */
	public void importFromXml(byte[] preciseXmlFile, ObjectHolder<Boolean> objectHolder) {
		objectHolder.setObject(getServices().importFromXml(preciseXmlFile));
	}
	
}

